﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

using Qianwei.Model;
using Qianwei.Biz;
using Qianwei.Common.Extension;

namespace Qianwei.Web
{
    public partial class SocialRecruitment : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SetTitle();
                SetJobs();
            }
        }

        private void SetTitle()
        {
            string url = System.IO.Path.GetFileName(Request.Url.AbsolutePath);
            IList<page_info> pageinfo = PageInfoManager.Instance.QueryPageInfo(string.Format("Page_Url='{0}'", url));
            if (pageinfo == null || pageinfo.Count == 0)
            {
                lcontenttitle.Text = "未知标题";
                return;
            }
            page_info pagenew = pageinfo.First();
            lcontenttitle.Text = pagenew.Page_Title;
            //lcontent.Text = pagenew.Page_Content;
        }

        private void SetJobs()
        {
            StringBuilder strjobs = new StringBuilder();
            IList<job_info> jobs = JobInfoManager.Instance.QueryJobInfo(null, "create_time desc");
            var newspager = Common.DataPaging<job_info>.GetDataSource(AspNetPager, jobs);

            foreach (var np in newspager)
            {
                strjobs.Append("<table width=\"629\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#808080\" border=\"1\"");
                strjobs.Append("style=\"border-collapse: collapse; font-size: 12px; color: #636363;\">");
                strjobs.AppendFormat("<tr><td width=\"115\" bgcolor=\"#F3F3DE\"><div align=\"center\">招聘对象</div></td><td width=\"510\" bgcolor=\"#F8FCF8\">{0}</td></tr>", np.Job_Position);
                strjobs.AppendFormat("<tr><td width=\"115\" bgcolor=\"#F3F3DE\"><div align=\"center\">招聘人数</div></td><td width=\"510\" bgcolor=\"#F8FCF8\">{0}</td></tr>", np.Job_Number);
                strjobs.AppendFormat("<tr><td width=\"115\" bgcolor=\"#F3F3DE\"><div align=\"center\">工作地点</div></td><td width=\"510\" bgcolor=\"#F8FCF8\">{0}</td></tr>", np.Job_Address);
                strjobs.AppendFormat("<tr><td width=\"115\" bgcolor=\"#F3F3DE\"><div align=\"center\">工资待遇</div></td><td width=\"510\" bgcolor=\"#F8FCF8\">{0}</td></tr>", np.Job_Treatment);
                strjobs.AppendFormat("<tr><td width=\"115\" bgcolor=\"#F3F3DE\"><div align=\"center\">发布时间</div></td><td width=\"510\" bgcolor=\"#F8FCF8\">{0}</td></tr>", np.Publish_Time.ToString("yyyy-MM-dd"));
                strjobs.AppendFormat("<tr><td width=\"115\" bgcolor=\"#F3F3DE\"><div align=\"center\">有效期限</div></td><td width=\"510\" bgcolor=\"#F8FCF8\">{0}</td></tr>", np.Effective_Duration);
                strjobs.AppendFormat("<tr><td width=\"115\" height=\"22\" bgcolor=\"#F3F3DE\"><div align=\"center\">招聘要求</div></td><td width=\"510\" bgcolor=\"#F8FCF8\">{0}</td></tr>", np.Job_Requirement);
                strjobs.AppendFormat("<tr bgcolor=\"#FFFFFF\"><td width=\"627\" height=\"22\" colspan=\"2\"><div align=\"right\"><b><a href=\"AcceptJob.aspx?jid={0}\"><font color=\"#FF0000\">应聘此岗位</font></a><font color=\"#FF0000\"> </font></b></div></td></tr>", np.Job_Id);
                strjobs.Append("</table>");
            }

            lcontent.Text = strjobs.ToString();

        }

        #region Event
        protected void AspNetPager_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
        {
            AspNetPager.CurrentPageIndex = e.NewPageIndex;
            SetJobs();
        }
        #endregion
    }
}